const { DataTypes } = require('sequelize');
const sequelize = require('../config/database');

const SystemConfigs = sequelize.define('SystemConfigs', {
  id: {
    type: DataTypes.BIGINT,
    allowNull: false,
    autoIncrement: true,
    comment: '配置ID',
  },
  configKey: {
    type: DataTypes.STRING(100),
    allowNull: false,
    comment: '配置键',
  },
  configValue: {
    type: DataTypes.TEXT,
    allowNull: false,
    comment: '配置值',
  },
  description: {
    type: DataTypes.STRING(255),
    comment: '配置描述',
  },
  isSystem: {
    type: DataTypes.TINYINT,
    defaultValue: 1,
    comment: '是否系统配置',
  },
  deletedAt: {
    type: DataTypes.DATE,
    comment: '删除时间',
  },
  createdAt: {
    type: DataTypes.DATE,
    defaultValue: CURRENT_TIMESTAMP,
    comment: '创建时间',
  },
  updatedAt: {
    type: DataTypes.DATE,
    defaultValue: CURRENT_TIMESTAMP,
    comment: '更新时间',
  },
  createdBy: {
    type: DataTypes.BIGINT,
    comment: '创建人',
  },
  updatedBy: {
    type: DataTypes.BIGINT,
    comment: '修改人',
  }
}, {
  tableName: 'system_configs',
  comment: '系统配置表',
  timestamps: true,
  paranoid: true,
  underscored: true,
  createdAt: 'created_at',
  updatedAt: 'updated_at',
  deletedAt: 'deleted_at'
});

module.exports = SystemConfigs;
